package pers.echo.tester.utils;

import pers.echo.tester.enums.ResTypeEnum;

import java.time.LocalDateTime;


public class SNUtil {

    public static String getBulletSn(){
        StringBuilder builder= new StringBuilder("");
        builder.append("B-")
                .append(getDateSN());
        return builder.toString();
    }

    public static String getResSn(ResTypeEnum resTypeEnum){

        StringBuilder builder= new StringBuilder("");

        if(resTypeEnum==ResTypeEnum.LAND){
            builder.append("L-")
                    .append(getDateSN());
        }else if(resTypeEnum==ResTypeEnum.CKQ){
            builder.append("C-")
                    .append(getDateSN());
        }else if(resTypeEnum==ResTypeEnum.TKQ){
            builder.append("T-")
                    .append(getDateSN());
        }
        return builder.toString();
    }
    private static String getDateSN(){
        LocalDateTime dt = LocalDateTime.now();

        int month = dt.getMonth().getValue();
        int day = dt.getDayOfMonth();
        int hour = dt.getHour();
        int minute = dt.getMinute();
        StringBuilder builder = new StringBuilder();
        builder
                .append(String.valueOf(month<10?"0"+month:month))
                .append(String.valueOf(day<10?"0"+day:day)).append("-")
                .append(String.valueOf(hour<10?"0"+hour:hour))
                .append(String.valueOf(minute<10?"0"+minute:minute))
                .append(String.valueOf(dt.getSecond()));
        return builder.toString();
    }
    public static void main(String args[]){

        System.out.println(getBulletSn().length());
        System.out.println(getResSn(ResTypeEnum.LAND));
        System.out.println(getResSn(ResTypeEnum.CKQ));
        System.out.println(getResSn(ResTypeEnum.TKQ));
    }
}
